﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FDEE.Model
{

    public abstract class TendonBase
    {        
        /// <summary>
        /// 主编号
        /// </summary>
        public int MTendonMark;
        /// <summary>
        /// 张拉阶段
        /// </summary>
        public int StressStage;
        /// <summary>
        /// 股数
        /// </summary>
        public int StrandsNum;
        /// <summary>
        /// 截面积
        /// </summary>
        public double Area { get { return StrandsNum * GlobalFuncs.GetStrandArea(StrandsType); } }

        /// <summary>
        /// 预应力类别
        /// </summary>
        public eStrandClass StrandsType;
        /// <summary>
        /// 张拉方式
        /// </summary>
        public eForceType StressType;
        /// <summary>
        /// 张拉强度，MPa
        /// </summary>
        public double TransferStress;
        /// <summary>
        /// 张拉力
        /// </summary>
        public double JackingForce;
        /// <summary>
        /// 下料长度
        /// </summary>
        public double Length;
        /// <summary>
        /// 导管长度
        /// </summary>
        public double DuctLength;
        /// <summary>
        /// 理论长度
        /// </summary>
        public double TheoricalLength;
        /// <summary>
        /// 理论伸长量
        /// </summary>
        public double Elongation;

        public Dictionary<string, double> ReportLine;
        /// <summary>
        /// 单位重量
        /// </summary>
        public double UnitWeight { get { return GlobalFuncs.GetUnitWeight(StrandsType); } }
        /// <summary>
        /// 总长
        /// </summary>
        public double TotalLength { get { return Math.Round(StrandsNum * Length, 3, MidpointRounding.AwayFromZero); } }
        /// <summary>
        /// 总重量
        /// </summary>
        public double TotalWeight { get { return Math.Round(TotalLength * UnitWeight, 3, MidpointRounding.AwayFromZero); } }


        /// <summary>
        /// 构造函数
        /// </summary>
        public TendonBase(int tMark,int stage, eStrandClass typeStrand, int numStrand,eForceType isBothEnd,double jackingForce)
        {
            StressStage = stage;
            MTendonMark = tMark;
            StrandsType = typeStrand;
            StrandsNum = numStrand;
            StressType = isBothEnd;
            JackingForce = jackingForce;
            Length = 0;

        }

        /// <summary>
        /// 设置长度算法，所有子类必须实现。
        /// </summary>
        public abstract void SetLength();
        /// <summary>
        /// 设置伸长量算法，所有子类必须实现。
        /// </summary>
        public abstract void SetElongation(ref System.Data.DataTable dt,double dx=1e-3);

        /// <summary>
        /// 重写基类
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {

            if (MTendonMark == 0)
            {
                return base.ToString();

            }
            string m ="T"+ MTendonMark.ToString();
            m += "-";
            m += Length.ToString();
            return m;
        }

        /// <summary>
        /// 设置伸长量计算表格
        /// </summary>
        /// <param name="dx"></param>
        /// public abstract void SetElongTable(double dx = 1e-3);

    }
}
